package com.spider.interface3;

public class ClassDataImpl1 implements ClassDataInter{
    private Student[] allStudent;
    public ClassDataImpl1(Student[] allStudent) {
        this.allStudent = allStudent;
    }
    @Override
    public void printAllStudentInfos() {
        for (int i = 0; i < allStudent.length; i++) {
            Student s = allStudent[i];
            System.out.println(s.getName() + " " + s.getSex() + " " + s.getScore());
        }
    }

    @Override
    public void printAverageScore() {
        double sum =0;
        for (int i = 0; i < allStudent.length; i++) {
            Student s = allStudent[i];
            sum += s.getScore();
        }
        System.out.println("平均分是：" + sum / allStudent.length);
    }
}
